<%@ page import="java.sql.*,studentportal.*"%>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Student Portal</title>
<meta name="Microsoft Theme" content="indust 011">
</head>

<body background="indtextb.jpg" bgcolor="#FFFFFF" text="#000000" link="#3366CC" vlink="#666666" alink="#996600">

<table border="0" width="100%" bordercolorlight="#666666" bordercolordark="#000000">
  <tr>
    <td width="100%"><img border="0" src="StdPrtlbanner.jpg" width="846" height="65"><!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">&nbsp;<!--mstheme--></font></td>
  </tr>
</table>
</table>
<!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><!--mstheme--></font>
<table border="0" width="100%" bordercolorlight="#666666" bordercolordark="#000000">
  <tr>
    <td width="23%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
      <p align="center"><a href="AdminStudentHome.html">Students</a><!--mstheme--></font></td>
    <td width="17%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica"><p align="center"><a href="AdminFacultyHome.html">Faculties</a><!--mstheme--></font></td>
   
    <td width="20%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
      <p align="center"><a href="AdminNotificaiton.jsp">Notifications</a><!--mstheme--></font></td>

    <td width="20%">
      <!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
      <p align="center"><a href="Home.html">Home</a><!--mstheme--></font></td>
  </tr>
</table>

<!--mstheme--><font face="Trebuchet MS, Arial, Helvetica">
<font face="Trebuchet MS, Arial, Helvetica">
	<form method="POST" action="">
  
	  <p>
			<table align="center" border="0">
				<tr>
					<th>Student ID</th>
					<th>Student Name</th>
					<th>Student Address</th>
					<th>Student DOB</th>
					<th>Student Phone</th>
					<th>Student Email</th>
					<th>Student Admision Date</th>
					<th>Student Login Name</th>
					<th>Student Reg Status</th>
					<th>&nbsp;</th>
					<th>&nbsp;</th>
					<th>&nbsp;</th>
				</tr>
				<%
					Connection con=MySQLDriver.getConnection(); 
					Statement st=con.createStatement();
					ResultSet rs=null;
					System.out.println("After Statement");
					String stuid=request.getParameter("sid");
					String stustatus=request.getParameter("status");

					if(stuid!=null || stustatus!=null)
					{
						Connection con1=MySQLDriver.getConnection();
						Statement st1=con1.createStatement();
						int i=0;
						String ssss="update student_master set student_loign_status='Y'  where student_id='"+request.getParameter("sid")+"'";
						System.out.println(ssss);
						System.out.println(stustatus);
						if(stustatus.equals("N"))
						{
											i=st1.executeUpdate(ssss);
											if(i==1)
											{
												Statement st2=con1.createStatement();
												ResultSet rs2=st2.executeQuery("select * from student_master where student_id='"+request.getParameter("sid")+"'");
												rs2.next();
												String sid=rs2.getString(1);
												java.sql.Date sdoj=rs2.getDate(7);
												String sname=rs2.getString(8);
												rs2.close();
												st2.close();
												Statement st3=con1.createStatement();
												String qr="insert into student_login values('"+sid+"','"+sname+"','"+sname+"','"+sname+"',to_date('"+sdoj+"','yyyy-mm-dd'))";
												System.out.println(qr);
												int j=st3.executeUpdate(qr);
											}
						}
						if(stustatus.equals("Y"))
							i=st1.executeUpdate("update student_master set student_loign_status='N'  where student_id='"+request.getParameter("sid")+"'");
						con1.commit();
						st1.close();
						con1.close();
					}
					
					rs=st.executeQuery("select * from student_master where student_loign_status='N'");
					System.out.println("Hi");
					if(rs!=null)
					{
						while(rs.next())
						{
								System.out.println("In While");
								String sid=rs.getString(1);

				%>
					
						<tr>
							<td align="center"><%=sid%></td>
							<td align="center"><%=rs.getString(2)%></td>
							<td align="center"><%=rs.getString(3)%></td>
							<td align="center"><%=rs.getDate(4)%></td>
							<td align="center"><%=rs.getInt(5)%></td>
							<td align="center"><%=rs.getString(6)%></td>
							<td align="center"><%=rs.getDate(7)%></td>
							<td align="center"><%=rs.getString(8)%></td>
							<%String status=rs.getString(9);%>
							<td align="center"><%=status%></td>
							<td align="center">
							<a href="./NewStudentRegStatus.jsp?sid=<%=sid%>&status=<%=status%>">Update Status</a></td>
							<td align="center">
							<a href="./StudentRegServlet?sid=<%=sid%>&action=Delete">Delete</a></td>
						</td>
						</tr>
					
				<%
					
					}
					rs.close();
					st.close();
					con.close();
					}
					else
					{
				%>
					<tr>
							<td align="center" colspan="10">There is No New Students</td>
					</tr>
							
				<%
					}						
				%>
				
				</table>
	  </p>
	</form>
</font>

</body>

</html>

